﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hotnet.Entity;
using Hotnet.Dal.NSDalPicture;
using Ninject.Core;

namespace Hotnet.Biz.NSBizPicture
{
	public class BizPicture : BaseBiz<Picture>
	{

		private static DalPicture dalPicture = new DalPicture();

		public BizPicture() : base(dalPicture) { }

		/// <summary>
		/// 删除组中所有图片
		/// </summary>
		/// <param name="groupId"></param>
		public void DeleteAllByGroupId(int groupId)
		{
			dalPicture.DeleteBy(c => c.GroupID == groupId);
		}

		/// <summary>
		/// 需要缓存 
		/// </summary>
		/// <param name="groupId"></param>
		/// <returns></returns>
		public Picture[] List(int groupId)
		{
			//TODO 缓存
			var pictureArr = dalPicture.ListBy(p => p.GroupID == groupId).OrderBy(p => p.OrderInGroup).ToArray();
			return pictureArr;
		}

		public void AddPicture(Picture picture)
		{
			dalPicture.Insert(picture);
		}

		public Picture[] ListByGroupID(int groupId)
		{
			return dalPicture.ListBy<int>(pic => pic.GroupID == groupId, pic => pic.OrderInGroup ?? 0, false);
		}

		public Picture[] ListPictureIncludeSourceFrom(int groupId)
		{
			throw new NotImplementedException();
		}

		public Picture[] ListInIDs(int[] pictureIds)
		{
			return dalPicture.ListBy(x => pictureIds.Contains(x.PictureID));
		}

		

	}
}
